﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KeywordAuction
{
   public  class KeywordStrategyRaiseAll : StrategyBase
    {
        public override bool Action(Advertiser advertiser)
        {
            foreach (var item in advertiser.Biddings)
            {
                item.Bid+= RaiseValue;
            }
            return true;
        }
    }
   public class KeywordStrategyDropAll : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           foreach (var item in advertiser.Biddings)
           {
               if (item.Bid - DropValue< 0)
               {
                   return false;
               }
               item.Bid -= DropValue;
           }
           return true;
       }
   }
   public class KeywordStrategyHoldAll : IStrategy
   {
       public bool Action(Advertiser advertiser)
       {
           return true;
       }

       public string Id
       {
           get;
           set;
       }
       public KeywordStrategyHoldAll()
       {
           Id = Guid.NewGuid().ToString();
       }
   }


    //Hard
   public class KeywrodStrategyRaiseDrop : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           advertiser.Biddings.FirstOrDefault().Bid += RaiseValue;
           if (advertiser.Biddings.LastOrDefault().Bid - DropValue >= 0)
           {
               advertiser.Biddings.LastOrDefault().Bid -= DropValue;
           }
           else
           {
               return false;
           }
           return true;
       }
   }

   public class KeywrodStrategyRaiseHold : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           advertiser.Biddings.FirstOrDefault().Bid += RaiseValue;
           return true;
       }
   }
   public class KeywrodStrategyHoldRaise : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           advertiser.Biddings.LastOrDefault().Bid += RaiseValue;
           return true;
       }
   }
   public class KeywrodStrategyDropRaise : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           if (advertiser.Biddings.FirstOrDefault().Bid - DropValue >= 0)
           {
               advertiser.Biddings.FirstOrDefault().Bid -= DropValue;
           }
           else
           {
               return false;
           }
           advertiser.Biddings.LastOrDefault().Bid += RaiseValue;
           return true;
       }
   }

   public class KeywrodStrategyDropHold : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           if (advertiser.Biddings.FirstOrDefault().Bid - DropValue >= 0)
           {
               advertiser.Biddings.FirstOrDefault().Bid -= DropValue;
           }
           else
           {
               return false;
           }
           return true;
       }
   }

   public class KeywrodStrategyHoldDrop : StrategyBase
   {
       public override bool Action(Advertiser advertiser)
       {
           if (advertiser.Biddings.LastOrDefault().Bid - DropValue >= 0)
           {
               advertiser.Biddings.LastOrDefault().Bid -= DropValue;
           }
           else
           {
               return false;
           }
           return true;
       }
   }
}
